#ifndef TRANSFORMATIONS_H
#define TRANSFORMATIONS_H

#include <QImage>
#include <QColor>

/**
  * This Static Class includes methods related with transformations over common image elements
  */
class Transformations
{  

public:

    /**
      * Returns the X coordinate of the pixel number "nPixel" if it is ubicated in the image "img".
      *
      * @param img Image in which the pixel is located.
      * @param nPixel Number of the pixel (it is numbered starting with 0 in the top left corner).
      * @return Returns the X coordinate of the pixel number nPixel.
      */
    static inline int getX( QImage * img, int nPixel );

    /**
      * Returns the Y coordinate of the pixel number "nPixel" if it is ubicated in the image "img".
      *
      * @param img Image in which the pixel is located.
      * @param nPixel Number of the pixel (it is numbered starting with 0 in the top left corner).
      * @return Returns the Yd coordinate of the pixel number nPixel.
      */
    static inline int getY( QImage * img, int nPixel );

    /**
      * Returns a number which represents the position of the pixel (x,y) in the image "img" if is traversed in Z order.
      *
      * @param img Image in which the pixel is located.
      * @param x, y Pixel coordinates
      * @return Returns a number which represents the position of the pixel for a traversed in Z order.
      */
    static inline int getPixelNumber( QImage * img, int x, int y ) {return (int) x + y * img->width();}

    /**
      * This method generates a QList<int> including all the pixel's neighbors included into the image (if the pixel is on a
      * border, will exist same neighbors outside the image, and they will not be included).
      * @param img Image in which the pixel is located.
      * @param pixel Pixel from which we want to extract its neighbors.
      * @return Returns a QList<int> including all the pixel's neighbors included into the image
      */
    static QList<int> * getNeighboringPixels (QImage * img, int pixel);

    /**
      * This method returns the pixel intensity in the image "img".
      * @param img Image in which the pixel is located.
      * @param pixel Pixel from which we want to obtain its intensity.
      * @return Returns the intensity of the pixel in the image.
      */
    static int getIntensity(QImage * img, int pixel);

    static int getIntensity(QImage * img, int x, int y);
};

int Transformations::getX( QImage * img, int nPixel )
{
    return (int) nPixel % img->width();
}

int Transformations::getY( QImage * img, int nPixel )
{
    return (int) nPixel / img->width();
}

//int Transformations::getPixelNumber( QImage * img, int x, int y )
//{
//    return (int) x + y * img->width();
//}


#endif // TRANSFORMATIONS_H
